package unit;

import java.util.Comparator;

import junit.framework.TestCase;

import com.google.code.netcheckin.aprs.Station;
import com.google.code.netcheckin.util.StationCallCollator;
import com.google.code.netcheckin.util.StationCallSuffixCollator;

public class UStationCallCollator extends TestCase {

	public static final String CALL_LOW 	= "KB9JHU";
	public static final String CALL_MEDIUM	= "KC9JLU";
	public static final String CALL_HIGH	= "WB9TLH";

	protected Station stnLow;
	protected Station stnMedium;
	protected Station stnHigh;

	protected Comparator comp;

	public UStationCallCollator(String name) {
		super(name);
	}

	public void setUp() {
		stnLow = new Station();
		stnLow.setCallsign(CALL_LOW);
		stnMedium = new Station();
		stnMedium.setCallsign(CALL_MEDIUM);
		stnHigh = new Station();
		stnHigh.setCallsign(CALL_HIGH);
		comp = new StationCallCollator();
	}

	public void tearDown() {
		stnLow = null;
		stnMedium = null;
		stnHigh = null;
	}

	public void testAAEqual() {
		assertEquals("wrong answer", 0, comp.compare(stnLow, stnLow));
	}

	public void testABLess() {
		assertEquals("wrong answer", -1, comp.compare(stnLow, stnMedium));
	}

	public void testACGreater() {
		assertEquals("wrong answer", 1, comp.compare(stnHigh, stnMedium));
	}

	public void testADEqualMethod() {
		StationCallCollator scc = new StationCallCollator();
		assertTrue("fail equals", comp.equals(scc));
		assertFalse("fail obj", comp.equals(this));
		assertFalse("fail subclass", comp.equals(new StationCallSuffixCollator()));
		
	}

}
